<?php
	require_once $_SERVER['roottrivialchase']."/classes/ConnectToBD_tc.class.php";
	
	
	if( isset($_POST['question_fr']) )
	{
		$db_link=connectToBD_tc::connexion();
		$requete="INSERT INTO question_fr (enonce, reponse, theme) VALUES (\"".$_POST['question_fr']."\", \"".$_POST['reponse_fr']."\", \"".$_POST['theme']."\");";
		$reponse=$db_link->prepare($requete);
		$reponse->execute();
		if(!$reponse) {echo "Enregistrement echoue dans la BDD fr"; die();}
		$requete="INSERT INTO question_eng (enonce, reponse, theme) VALUES (\"".$_POST['question_en']."\", \"".$_POST['reponse_en']."\", \"".$_POST['theme']."\");";
		$reponse=$db_link->prepare($requete);
		$reponse->execute();
		if(!$reponse) {echo "Enregistrement echoue dans la BDD en"; die();}
		echo "Question bien enregistree.";
	}
	?>
	
	<form method="POST" action="questions.php">
	<table>
		<tr>
			<td><select name="theme">
			<option value="1">Histoire</option>
			<option value="2">Geographie</option>
			<option value="3">Divertissement</option>
			<option value="4">Art et litterature</option>
			<option value="5">Science et nature</option>
			<option value="6">Sport et loisirs</option>
		</select></td>
		<td><label for="question_fr">Question fr</label><input type="text" name="question_fr"/><br/></td>
		<td><label for="reponse_fr">Reponse fr</label><input type="text" name="reponse_fr"/><br/></td></tr>
		<tr><td></td>
		<td><label for="question_en">Question en</label><input type="text" name="question_en"/><br/></td>
		<td><label for="reponse_en">Reponse en</label><input type="text" name="reponse_en"/><br/></td>
		</tr>
	</table>
		
		<input type="submit" value="envoyer">
	</form>
		
		
	
	